<?php

namespace Database\Factories;

use App\Models\Order;
use Illuminate\Database\Eloquent\Factories\Factory;
use phpDocumentor\Reflection\Types\Self_;

class OrderFactory extends Factory
{
    /**
     * 定义工厂模型
     * @var string
     */
    protected $model= Order::class;
    public static $ORDER_STATUS = [
        'PLACE_ORDESUCCESS',
        'IN_CANCEL',
        'WAIT_SELLESEND_GOODS',
        'SELLEPART_SEND_GOODS',
        'WAIT_BUYEACCEPT_GOODS',
        'SELLEPART_SEND_GOODS',
        'WAIT_BUYEACCEPT_GOODS',
        'FUND_PROCESSING',
        'IN_ISSUE',
        'IN_FROZEN',
        'WAIT_SELLEEXAMINE_MONEY',
        'RISK_CONTROL',
        'FINISH',
        'Unfulfillable',
        'fulfilled',
        'null',
        'partial',
        'restocked',
    ];

    /**
     * Define the model's default state.
     * 工程模型定义
     *
     * @return array
     */
    public function definition()
    {
        return [
            'shop_code' => $this->faker->numerify('N#'),//店铺编码
            'in_order_id' => $this->faker->numerify('N#').'-'.$this->faker->date($format = 'Ymd', $max = 'now').'-'.$this->faker->numerify('###'),//内部订单id
            'order_id' => $this->faker->numerify('##################'),//外部订单号
            'sys_create_time' => $this->faker->dateTime('now'),//订单系统下单时间
            'sys_update_time' => $this->faker->dateTime('now'),//订单系统修改时间
            'sys_pay_time' => $this->faker->dateTime('now'),//订单系统支付时间
            'plat_stock_time' => $this->faker->dateTime('now'),//订单出库时间
            'plat_end_time' => $this->faker->dateTimeBetween('+5 days', $endDate = '+2 weeks'),//订单平台结束时间
            'merge_status' => $this->faker->randomDigitNotNull,//合并状态1未合并2可合并3已合并4已被合并
            'type' => $this->faker->randomDigitNotNull,//1自建站2速卖通3亚马逊4自主品牌5线下单
            'order_status' => $this->faker->randomElement(self::$ORDER_STATUS),//PLACE_ORDESUCCESS:等待买家付款; IN_CANCEL:买家申请取消; WAIT_SELLESEND_GOODS:等待您发货; SELLEPART_SEND_GOODS:部分发货; WAIT_BUYEACCEPT_GOODS:等待买家收货; FUND_PROCESSING:买卖家达成一致，资金处理中； IN_ISSUE:含纠纷中的订单; IN_FROZEN:冻结中的订单; WAIT_SELLEEXAMINE_MONEY:等待您确认金额; RISK_CONTROL:订单处于风控24小时中，从买家在线支付完成后开始，持续24小时; FINISH:已结束的订单;Unfulfillable无法处理；自建站：fulfilled:已完成，null:未完成,partial:部分完成。restocked:缺货
            'in_order_status' => $this->faker->randomDigitNotNull,//内部订单状态(1待制单,2待打印3待发货,4已出库,5部分发货6,已废除)
            'in_order_amount' => $this->faker->randomFloat(2,30,1200),//订单总金额 获取速卖通的新订单金额(new_order_amount)
            'in_ordear_code' =>  $this->faker->currencyCode,//订单总金额币种
            'in_order_total' => $this->faker->randomFloat(2,30,1200),//折扣后的订单金额
            'in_order_total_code' => $this->faker->currencyCode,//货币种类
            'order_number' => $this->faker->randomDigitNotNull,//订单数量
            'deliver_comment' => $this->faker->realText(200,2),//发货备注
            'customer_comment' => $this->faker->realText(200,2),//客服备注
            'buyer_memo' => $this->faker->realText(200, 2),//买家备注
            'buyer_name'=>$this->faker->name,//买家姓名
        ];
    }

}
